﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2
{
    /// <summary>
    /// 枚举五个元素
    /// </summary>
    enum MapType
    {
        Space = 0,
        Wall = 1,
        Player = 2,
        Monster = 3,
        Money = 4,
        Monster1=5
    }

    class Block
    {
        /// <summary>
        /// 定义每个方块长100宽100，获取坐标
        /// </summary>
        public Rectangle Rectangle
        {
            get
            {
                return new Rectangle(Point.Y * 100, Point.X * 100, 100, 100);
            }
        }
        
        public Point Point { get; set; }

        public MapType MapType { get; set; }
        /// <summary>
        /// 获取每个枚举的物理坐标和矩阵坐标
        /// </summary>
        /// <param name="point"></param>
        /// <param name="mapType"></param>
        public Block(Point point, MapType mapType)
        {
            Point = point;
            MapType = mapType;
        }
        /// <summary>
        /// 绘制每个元素
        /// </summary>
        /// <param name="g"></param>
        /// <param name="direction"></param>
        public void Draw(Graphics g,Direction direction)
        {
            switch (MapType)
            {
                case MapType.Space:
                    g.FillRectangle(new SolidBrush(Color.Black), Rectangle);//绘制空地
                    break;
                case MapType.Wall:
                    g.DrawImage(Properties.Resources.block, Rectangle);//绘制墙
                    break;
                case MapType.Player://绘制小人
                    switch (direction)
                    {
                        case Direction.Up:
                            g.DrawImage(Properties.Resources.pup, Rectangle);
                            break;
                        case Direction.Right:
                            g.DrawImage(Properties.Resources.pright, Rectangle);
                            break;
                        case Direction.Down:
                            g.DrawImage(Properties.Resources.pdown, Rectangle);
                            break;
                        case Direction.Left:
                            g.DrawImage(Properties.Resources.pleft, Rectangle);
                            break;
                    }
                    break;
                case MapType.Monster:
                    g.DrawImage(Properties.Resources.pinkghost, Rectangle);//绘制幽灵
                    break;
                case MapType.Money:
                    g.DrawImage(Properties.Resources.money, Rectangle);//绘制金币
                    break;
                case MapType.Monster1:
                    g.DrawImage(Properties.Resources.orangeGhost, Rectangle);
                    break;
            }
        }
    }
}
